package com.aierkeji.b2c.entity.snapshot;

import com.aierkeji.b2c.entity.AkjAuser;
import com.aierkeji.b2c.entity.AkjAuserRole;
import com.aierkeji.b2c.utils.WebUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

@Entity
@Table(name="akj_auser")
public class AkjAuserSnap {

    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    @Column(name="id",length=32)
    private String id;

    @Column(length=27)
    private String name;

    @Column(length=27)
    private String account;

    @Column(length=128)
    private String pwd;

    @Column(columnDefinition="datetime")
    private Timestamp createTime;


    @Column(length=1)
    private Boolean isDelete;

    @Column(name="leader_id",insertable = false, updatable = false)
    private String leaderId;



    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Boolean getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Boolean isDelete) {
        this.isDelete = isDelete;
    }

    public String getLeaderId() {
        return leaderId;
    }

    public void setLeaderId(String leaderId) {
        this.leaderId = leaderId;
    }

    public Boolean checkParamsNull(){
        return WebUtils.checkParamsIsNull(this.account,this.name,this.pwd);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AkjAuserSnap that = (AkjAuserSnap) o;
        return id.equals(that.id) &&
                name.equals(that.name) &&
                account.equals(that.account);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, account);
    }
}
